package com.soso.controller;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.soso.entity.Modules;
import com.soso.service.ModulesService;

@RestController
@CrossOrigin
@RequestMapping("/mod")
public class zhModulesController {
	
	  @Autowired 
	  ModulesService ms;
	  
	  @RequestMapping("/getAll")
	  public Object getAll(Integer id) {
		return ms.getAll(id);
	  }
	 
	  @RequestMapping("/getById")
	  public Map<String, Object> getById(Integer id) {
			Map<String, Object> map=new HashMap<String, Object>();
			try {
				map.put("success", true);
				map.put("message", ms.getById(id));
			} catch (Exception e) {
				map.put("success", false);
				map.put("message", "加载失败");
			}
			return map;
		}
	  
	  
	  @RequestMapping("/save")
	  public Map<String, Object> save(Modules m){
	 Map<String,Object> map=new HashMap<String, Object>();
	 Integer i=ms.save(m);
	 if(i==0) {
		 map.put("success", true);
		 map.put("message", "操作成功！");
	 }else {
		 map.put("success", true);
		 map.put("message", "操作成功！");
	 }
		  return map;
	  }
	  
	  
	  
	  @RequestMapping("/del")
	  public Map<String, Object> del(Integer id){
	 Map<String,Object> map=new HashMap<String, Object>();
	 Integer i=ms.deletle(id);
	 if(i==0) {
		 map.put("success", true);
		 map.put("message", "操作成功！");
	 }else {
		 map.put("success", true);
		 map.put("message", "操作成功！");
	 }
		  return map;
	  }
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
}
